extends Node2D
var passed:bool=false

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	pass
var _shootting:bool=false
func close_waterball()->void:
	_shootting=false
	for child in $WaterBall.get_children():
		child.reset()

func _on_start_area_entered(area: Area2D) -> void:
	if not area.is_in_group("player"):return
	Global.fighting=true
	%ColorFull.water()
	start_test()
	pass # Replace with function body.

func start_test()->void:
	$NoGravity.set_deferred("gravity_space_override",Area2D.SPACE_OVERRIDE_REPLACE)
	create_tween().tween_property(%Dizzy.material,"shader_parameter/strength",0.02,3)
	$TestArea.set_collision_layer_value(1,true)
	$Start.set_deferred("monitoring",false)
	Global.display_tip.emit("w a s d 移动,躲开水球")
	$Leaf.emitting=true
	_shootting=true
	var children:=$WaterBall.get_children()
	for child in children:
		if _shootting:
			child.shoot()
			await get_tree().create_timer(4).timeout
		else:
			end_test()
			return
	await get_tree().create_timer(6).timeout
	if not _shootting:
		end_test()
		return
	passed=true
	end_test()
func end_test()->void:
	$NoGravity.set_deferred("gravity_space_override",Area2D.SPACE_OVERRIDE_DISABLED)
	create_tween().tween_property(%Dizzy.material,"shader_parameter/strength",0.0,3)
	_shootting=false
	$TestArea.set_collision_layer_value(1,false)
	if not passed:$Start.set_deferred("monitoring",true)
	if passed:%Camera.limit_right=100000000
	$Leaf.emitting=false
	if passed:
		Global.display_str.emit("水的冲刷使你清醒了许多")
	else:
		Global.display_str.emit("还不够吗...")
		%ColorFull.default()
	Global.fighting=false
